#!/bin/bash
which cmake &> /dev/null
if [ "$?" != "0" ]; then
  echo "cmake was not found !!!"
  exit 1 
fi

export XRDDMSYS=$1
if [ "x$XRDDMSYS" == "x" ]; then
  export XRDDMSYS=`pwd`
fi
export XROOTD_DIR=$XRDDMSYS
export ALIEN_DIR=$XRDDMSYS

MYDIR=`cd $XRDDMSYS/..;pwd`
if [ -d $MYDIR ];then
	export ROOTSYS="$MYDIR/root"
	export PATH="$ROOTSYS/bin:$PATH"
	export LD_LIBRARY_PATH="$ROOTSYS/lib:$LD_LIBRARY_PATH"
fi

export APPMON_DIR=$ALIEN_DIR/ 

cmake . -DCMAKE_INSTALL_PREFIX:PATH=$XRDDMSYS -DCMAKE_BUILD_TYPE=Debug

echo "\$XRDDMSYS=$XRDDMSYS"
echo "\$XROOTD_DIR=$XROOTD_DIR"
echo "\$ALIEN_DIR=$ALIEN_DIR"
echo "\$ROOTSYS=$ROOTSYS"